home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / enhkbd.zip / KBDDEMO.PAS < prev   
Pascal/Delphi Source File  |  1993-01-04  |  1KB  |  51 lines

  1. {
  2.  Demonstration of EnhKbd unit. See the comments within that unit
  3.  for more information.
  4. }
  5.  
  6. {$R-,S-}
  7.  
  8. program Kbd;
  9. uses
  10.   EnhKbd,
  11.   Dos;
  12.  
  13. const
  14.   Digits : array[0..$F] of Char = '0123456789ABCDEF';
  15. var
  16.   KW : Word;
  17.  
  18.   function HexW(W : Word) : string;
  19.     {-Return hex string for word}
  20.   begin
  21.     HexW[0] := #4;
  22.     HexW[1] := Digits[hi(W) shr 4];
  23.     HexW[2] := Digits[hi(W) and $F];
  24.     HexW[3] := Digits[lo(W) shr 4];
  25.     HexW[4] := Digits[lo(W) and $F];
  26.   end;
  27.  
  28.   function ReadKeyWord : Word;
  29.     {-Return ASCII code in low byte, scan code in high byte}
  30.   var
  31.     Regs : registers;
  32.   begin
  33.     with Regs do begin
  34.       ah := $0;
  35.       intr($16, Regs);
  36.       ReadKeyWord := ax;
  37.     end;
  38.   end;
  39.  
  40. begin
  41.   WriteLn('Enhanced keyboard? ', HasEnhancedKbd);
  42.   WriteLn('Press keys to see scan words.');
  43.   WriteLn('Press Enter to quit, Ctrl-Enter to toggle enhanced keys');
  44.   repeat
  45.     KW := ReadKeyWord;
  46.     WriteLn(HexW(KW));
  47.     if KW = $1C0A then
  48.       EnableEnhanced := not EnableEnhanced;
  49.   until lo(KW) = 13;
  50. end.
  51.